/*
 * Copyright (c) 2016 yunmle.com(四川云麦尔科技).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 */
package com.imu.utils;

import java.util.UUID;
import java.util.zip.CRC32;

/**
 * 
 * @description ID生成工具类
 * @author xuyq - chainisit@126.com
 * @author sunhongwei
 * @email sunhongwei@gmail.com
 * @date 2017年11月4日 上午11:07:35
 */
public class IDUtils 
{
	private static final IDWorker idWorker = new IDWorker(5, 1);
	  
	public static final Long getId() 
	{
		return idWorker.nextId();
	}
	
	public static String getUID()
  	{
		UUID uuid = UUID.randomUUID();
		return uuid.toString().replace("-","");
  	}
	
	public static final String getOrder() 
	{
		return DateUtils.now() + getId();
	}
  
	public static String getUUID()
  	{
		UUID uuid = UUID.randomUUID();
		return uuid.toString().replace("-","").toUpperCase();
  	}
	
	/**
	 * @param deviceId
	 * @return int 
	 * CRC32
	 */
	public static long getCRC32()
	{
        CRC32 crc32 = new CRC32();  
        crc32.update(getUID().getBytes());
        return crc32.getValue();
	}
}